import { defineStore } from "pinia";
import piniaPersistConfig from "@/stores/helper/persist";

export const useIconsStore = defineStore("neohesperidose-icons", {
  state: (): IconState => ({
    iconList: []
  }),
  actions: {
    setIconList() {
      this.iconList = Object.keys(import.meta.glob("@/assets/icons/*.svg"))
        .map(v => {
          const fileName = v.split("/").pop();
          return fileName ? fileName.replace(".svg", "") : "";
        })
        .filter(name => name !== "");
    }
  },
  persist: piniaPersistConfig("neohesperidose-icons")
});
